/*
 * ProjectValidator.java
 *
 * Project: TECHWATCH - TESTING TECHNOLOGIES
 *
 * Copyright 2008 by ELCA Informatique SA
 * Av. de la Harpe 22-24, 1000 Lausanne 13
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of ELCA Informatique SA. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license
 * agreement you entered into with ELCA.
 */

package ch.elca.training.validator;

import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import ch.elca.training.dom.Project;
import ch.elca.training.dom.ProjectQuery;

/**
 * Validator for object {@link Project}.
 *
 * <script type="text/javascript">printFileStatus
 *   ("$URL: https://cvs.elca.ch/subversion/cxnet-portal/trunk/etc/eclipse/preferences_2008_03_03.epf $",
 *    "$Revision: 334 $",
 *    "$Date: 2008-03-03 16:07:32 +0700 (Mon, 03 Mar 2008) $",
 *    "$Author: qkp@ELCA.CH $"
 *    "$Id:$"
 * );</script>
 *
 * @author qkp
 */
public class SearchProjectsValidator implements Validator {

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
        return ProjectQuery.class.isAssignableFrom(clazz);
    }

    /**
     * {@inheritDoc}
     */
    public void validate(Object target, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "searchNumber", "fieldEmpty",
                new Object[] {new DefaultMessageSourceResolvable("project_number")});
        /*ValidationUtils.rejectIfEmptyOrWhitespace(errors, "searchName", "fieldEmpty",
                new Object[] {new DefaultMessageSourceResolvable("project_name")});
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "searchCustomer", "fieldEmpty",
                new Object[] {new DefaultMessageSourceResolvable("project_customer")});
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "searchStatus", "fieldEmpty",
                new Object[] {new DefaultMessageSourceResolvable("project_status")});*/
    }
}